/* Maybe there're something to do with `d`, I think. */
#include <bits/stdc++.h>
using namespace std;

using LL=long long;
LL T;
LL n, m, L, V;
LL d[100000], v[100000], a[100000], p[100000];
LL ans1, ans2;

void solve(){
    cin>> n>> m>> L>> V;
    LL least = 0, left = -1, right = L+1;
    ans1 = ans2 = 0;
    for (LL i=0; i<n; i++)
        cin>> d[i]>> v[i]>> a[i];
    for (LL i=0; i<m; i++)
        cin>> p[i];
    for (LL i=0; i<n; i++){
        if (a[i] == 0 && v[i]>V){
            least = 1;
            ans1++;
        }else if (a[i] > 0 && v[i]*v[i] > V*V-2*a[i]*(p[m-1]-d[i])){
            LL x = (V*V - v[i]*v[i]) / (2*a[i]);
            right = right < x? right:x;
            ans1++;
        }else if (a[i] < 0 && v[i]*v[i] > V*V-2*a[i]*p[0]){
            LL x = (V*V - v[i]*v[i]) / (2*a[i]);
            left = left > x? left:x;
            ans1++;
        }
    }
    if (left != -1) ans2++;
    if (right != L+1) ans2++;
    if (left >= right) ans2 = 1;
    if (least && ans2==0) ans2 = 1;
    cout<< ans1<< " "<< m-ans2<< endl;
}

int main(){
    auto _1 = freopen("detect.out", "w", stdout);
    auto _2 = freopen("detect.in" , "r", stdin );
    cin>> T;
    for (LL i=0; i<T; i++)
        solve();
    return 0;
}
